﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace SuYuanSystem.Repositories
{
    public interface IRepository<TEntity> where TEntity : class
    {
        Task<int> Insert(TEntity entity);
        Task<int> AddRange(IEnumerable<TEntity> entities);
        Task<int> Delete(int id);
        Task<int> DeleteRange(IEnumerable<int> ids);
        Task<List<TEntity>> GetAll();
        /// <summary>
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns
        /// 根据条件查询多条>
        Task<List<TEntity>> QueryAsync(Expression<Func<TEntity, bool>> predicate);
        Task<TEntity> GetById(int id);
        /// <summary>
        /// 根据条件查询是否存在
        /// </summary>
        /// <param name="predicate"></param>
        /// <returns></returns>
        Task<bool> ExistsAsync(Expression<Func<TEntity, bool>> predicate);
        Task<int> Update(TEntity entity);
        Task<int> UpdateRange(IEnumerable<TEntity> entities);

        Task<TEntity> QueryFirstAsync(Expression<Func<TEntity, bool>> predicate);
    }
}
